<template>
  <div class="view-fill">
    <div
      v-if="
        !receivingDetailInfo.visible &&
        !consumeDetailInfo.visible &&
        !modifyInfo.visible &&
        !modifyAcceptInfo.visible &&
        !modifyAcceptNumberInfo.visible &&
        !withTableOrderDetailInfo.visible &&
        !withTableAcceptOrderDetailInfo.visible
      "
      class="app-container-flex"
    >
      <NewFullScreen
        v-model="showDialog"
        :title="title"
        :needOperateAffair="true"
        :operateAffairData="affairTableInfo"
        @returnBack="$emit('returnBack')"
      >
        <template v-slot:full-button>
          <el-button
            v-if="
              $permission('withTableRecordOrder:submit') &&
              infoList.data.status === 1
            "
            @click="submit"
            >提交</el-button
          >
          <el-button
            v-if="
              $permission('withTableRecordOrder:update') &&
              infoList.data.status === 1
            "
            @click="update"
            >修改</el-button
          >
          <el-button
            v-if="
              $permission('withTableRecordOrder:ratify') &&
              infoList.data.status === 2
            "
            @click="ratify"
            >批准</el-button
          >
          <el-button
            v-if="
              $permission('withTableRecordOrder:reject') &&
              infoList.data.status === 2
            "
            @click="reject"
            >驳回</el-button
          >
          <el-button
            v-if="
              $permission('withTableRecordOrder:revoke') &&
              infoList.data.status === 2
            "
            @click="revoke"
            >撤回</el-button
          >
          <el-button v-if="canPrintQrCode" @click="pringQrCode"
            >打印二维码</el-button
          >
          <PopoverPrint
            ref="popoverShow"
            v-model:popoverVisible="popoverVisible"
            :canPrint="canPrint"
            :templateArr="templateArr"
            @tempClick="tempClick"
            @print="print"
          ></PopoverPrint>
          <!-- <el-button
            v-if="$permission('withTableRecordOrder:printOrderDetails')"
            @click="print"
            >打印</el-button
          > -->
          <el-button
            v-if="$permission('withTableRecordOrder:excelOrderDetails')"
            @click="exportExcel"
            >导出excel</el-button
          >
        </template>
        <div class="model-panel">
          <div class="model-panel-title">
            <p>{{ $t('basic_information') }}</p>
          </div>
          <div class="model-panel-body">
            <basic-information :info="infoList"></basic-information>
          </div>
        </div>
        <div class="model-panel">
          <div class="model-panel-title">
            <p>{{ $t('detailInfo') }}</p>
          </div>
          <div class="model-panel-body">
            <div class="layui-card-body">
              <!-- 表格 -->
              <page-table
                :refresh="tableInfo.refresh"
                :init-curpage="tableInfo.initCurpage"
                v-model:data="tableInfo.data"
                :pager="false"
                :field-list="tableInfo.fieldList"
                :handle="tableInfo.handle"
                :check-box="false"
                :tab-index="true"
              >
              </page-table>
            </div>
          </div>
          <div class="model-panel">
            <div class="model-panel-title">
              <p>{{ $t('operateAffair') }}</p>
            </div>
            <div class="model-panel-body">
              <div class="flex_full_item">
                <!-- 表格 -->
                <el-tabs v-model="activeName" @tab-click="handleTabClick">
                  <el-tab-pane
                    class="model-panel-title"
                    label="跟台记录关联表"
                    name="first"
                  >
                    <page-table
                      v-model:data="mainRelationTableInfo.data"
                      :pager="false"
                      :check-box="false"
                      :field-list="mainRelationTableInfo.fieldList"
                    >
                      <template v-slot:col-relationOrderNo="scope">
                        <span
                          class="slip-edit"
                          @click="showDetailLink(scope.row)"
                          >{{ scope.row.relationOrderNo || '-' }}</span
                        >
                      </template>
                    </page-table>
                  </el-tab-pane>
                </el-tabs>
              </div>
            </div>
          </div>
        </div>
      </NewFullScreen>
    </div>
    <!-- 修改 -->
    <Modify
      v-if="modifyInfo.visible"
      :order-id="modifyInfo.orderId"
      v-model:visible="modifyInfo.visible"
      :title="modifyInfo.title"
      @returnModify="returnModify"
    />
    <ModifyByAccept
      v-if="modifyAcceptInfo.visible"
      v-model:visible="modifyAcceptInfo.visible"
      :title="modifyAcceptInfo.title"
      :order-id="modifyAcceptInfo.orderId"
      :accept-order-id="modifyAcceptInfo.acceptOrderId"
      :accept-order-no="modifyAcceptInfo.acceptOrderNo"
      :supplier-id="modifyAcceptInfo.supplierId"
      :supplier-name="modifyAcceptInfo.supplierName"
      @returnModify="returnModify"
    />
    <ModifyByAcceptNomberMode
      v-if="modifyAcceptNumberInfo.visible"
      v-model:visible="modifyAcceptNumberInfo.visible"
      :title="modifyAcceptNumberInfo.title"
      :order-id="modifyAcceptNumberInfo.orderId"
      :accept-order-id="modifyAcceptNumberInfo.acceptOrderId"
      :accept-order-no="modifyAcceptNumberInfo.acceptOrderNo"
      :supplier-id="modifyAcceptNumberInfo.supplierId"
      :supplier-name="modifyAcceptNumberInfo.supplierName"
      @returnModify="returnModify"
    />
    <individual-details
      v-if="individualInfo.visible"
      v-model:show-dialog="individualInfo.visible"
      :query="individualInfo.query"
      :info="individualInfo.info"
      :page-status="canPrintQrCode"
      @returnBack="returnBack"
    />
    <WithTableOrderDetails
      v-if="withTableOrderDetailInfo.visible"
      :id="withTableOrderDetailInfo.id"
      v-model:visible="withTableOrderDetailInfo.visible"
      @returnBack="returnModify"
    />
    <WithTableAcceptOrderDetails
      v-if="withTableAcceptOrderDetailInfo.visible"
      :id="withTableAcceptOrderDetailInfo.id"
      v-model:visible="withTableAcceptOrderDetailInfo.visible"
      @returnBack="returnModify"
    />
    <ReceivingDetail
      v-if="receivingDetailInfo.visible"
      v-model:visible="receivingDetailInfo.visible"
      :id="receivingDetailInfo.id"
      @returnBack="returnModify"
    />
    <ConsumeDetail
      v-if="consumeDetailInfo.visible"
      v-model:visible="consumeDetailInfo.visible"
      :id="consumeDetailInfo.id"
      @returnBack="returnModify"
    />
    <chose-printer :visible="printerInfo.visible" @callBack="printerCallBack" />
    <page-dialog
      :title="revokeDialogInfo.title"
      v-model:visible="revokeDialogInfo.revokeVisible"
      :width="revokeDialogInfo.width"
      :bt-loading="revokeDialogInfo.btLoading"
      :bt-list="revokeDialogInfo.btList"
    >
      <page-form
        class="paddingBox order-model-formBox flex_wrap_start_start"
        :data="formInfo.data"
        :field-list="formInfo.fieldList"
        :label-width="formInfo.labelWidth"
        style="width: 100%"
      >
        <template v-slot:form-invalidQty>
          <div
            v-if="formInfo.data.codeType === 1 || formInfo.data.codeType === 4"
          >
            <el-input-number
              v-model.lazy="formInfo.data.largeUnitQty"
              clearable
              style="width: 100%"
              controls-position="right"
              :precision="
                formInfo.data.qtyOperateMode === 0 ||
                formInfo.data.qtyOperateMode === 2
                  ? 0
                  : systemConfig.qty_show_precision
              "
              @change="changeLarge($event, formInfo.data)"
              :min="0"
              :max="largeMax(formInfo.data)"
            />
            <span style="padding-left: 10px; position: absolute">{{
              formInfo.data.unitName
            }}</span>

            <div
              v-if="
                formInfo.data.unitConvertCoefficient > 1 &&
                formInfo.data.qtyOperateMode === 2
              "
            >
              <el-input-number
                style="width: 100%; margintop: 18px"
                v-model.lazy="formInfo.data.smallUnitQty"
                clearable
                controls-position="right"
                :precision="0"
                :min="0"
                :max="smallMax(formInfo.data)"
              />
              <span style="padding-left: 10px; position: absolute">{{
                formInfo.data.calcUnitName
              }}</span>
            </div>
          </div>
          <span
            v-else-if="
              formInfo.data.codeType === 2 || formInfo.data.codeType === 3
            "
            >{{ $fn.qtyFormatter(formInfo.data.qty) }}</span
          >
        </template>
      </page-form>
    </page-dialog>
  </div>
</template>

<script setup name="details">
import BasicInformation from '@/components/BasicInformation/index'
import PageTable from '@/components/PageTable/index'
import chosePrinter from '@/components/ChosePrinter/index'
import IndividualDetails from './IndividualDetails'
import Modify from './modify'
import ModifyByAccept from './modifyByAccept'
import ModifyByAcceptNomberMode from './modifyByAcceptNomberMode'
import WithTableOrderDetails from '../withTableOrder/details'
import WithTableAcceptOrderDetails from '../withTableAcceptOrder/details'
import { getCustomizeSetting } from '@/api/customize'
import {
  getWithTableRecordOrderById,
  getWithTableRecordOrderDetailAll,
  withTableRecordOrderRatify,
  withTableRecordOrderRejecty,
  withTableRecordOrderSubmit,
  withTableRecordOrderRevoke,
  withTableRecordOrderPrintOrder,
  withTableRecordOrderExcelOrder,
  withTableRecordOrderPrintQrCode,
  withTableRecordOrderDetailPrintQrCodeVO,
  withTableRecordOrderRevokeDetail,
} from '@/api/withTable.js'
import { detailConsumeOrder } from '@/api/stock.js'
import { fatchTemplateByCode } from '@/api/base'
import { orderOpAffairAll } from '@/api/affair'
import { getMainRelationOrderAll } from '@/api/mapping'
import ReceivingDetail from '@/views/stock/receiving/detail'
import ConsumeDetail from '@/views/stock/consumeOrder/detail'
import { doPrint } from '@/utils/exportUtil.js'
import { selectByCodeAndDept } from '@/api/report.js'
import { updatePrintCount } from '@/api/mapping'

const { proxy } = getCurrentInstance()
const emit = defineEmits()

const props = defineProps(['visible', 'id'])

const title = ref('跟台记录详情')
const systemConfig = ref(proxy.$store.state.permission.systemConfig)
const activeName = ref('first')
const isNotEmptyString = ref('')
const infoList = reactive({
  data: {},
  fieldList: [
    {
      label: '单号',
      value: 'orderNo',
    },
    {
      label: '手术名称',
      value: 'surgeryName',
    },
    {
      label: '手术时间',
      value: 'surgeryTime',
    },
    {
      label: '手术地点',
      value: 'surgeryPlace',
    },
    {
      label: '供应商名称',
      value: 'supplierName',
    },
    {
      label: '验收单号',
      value: 'acceptOrderNo',
    },
    {
      label: '状态',
      value: 'statusValue',
    },
    { label: '创建人', value: 'createUserName', type: 'text' },
    { label: '创建时间', value: 'createTime', type: 'text' },
    { label: '更新人', value: 'updateUserName', type: 'text' },
    { label: '更新时间', value: 'updateTime', type: 'text' },
    {
      label: '业务日期',
      value: 'businessDate',
      type: 'text',
    },
    {
      label: '备注',
      value: 'remark',
      type: 'popover',
    },
  ],
})
const tableInfo = reactive({
  refresh: 1,
  initCurpage: 1,
  data: [],
  fieldList: [],
  handle: {
    fixed: 'right',
    label: '操作',
    width: '150',
    btList: [
      {
        label: '打印二维码',
        event: printSingleQrCode,
        show: proxy.$permission('withTableRecordOrder:printCode'),
        ifRender: ifRenderValue,
      },
      {
        label: '个体详情',
        event: showDetail,
        show: proxy.$permission('withTableRecordOrder:individualDetails'),
      },
      {
        label: '无痕撤回',
        event: noTraceRevoke,
        show: proxy.$permission('withTableRecordOrder:noTraceRevoke'),
        ifRender: ifRenderRevoke,
      },
    ],
  },
})
const filterInfo = reactive({
  query: {
    customizeUserVO: {},
    queryMap: {
      orderId: {
        queryType: 'EQUALS',
        queryCategory: 'AND',
        value: props.id,
      },
    },
    queryParams: {},
  },
})
const affairTableInfo = reactive({
  api: orderOpAffairAll,
  query: {
    orderType: 76,
    orderId: props.id,
    sort: 'operate_time desc',
  },
})
const mainRelationTableInfo = reactive({
  refresh: 1,
  initCurpage: 1,
  data: [],
  query: {
    mainOrderType: 76,
    mainOrderId: props.id,
    sort: 'id desc',
  },
  fieldList: [
    { label: '跟台记录表单号', value: 'mainOrderNo' },
    { label: '单据类型', value: 'relationOrderTypeValue' },
    {
      label: '关联生成单据表单号',
      value: 'relationOrderNo',
      type: 'slot',
    },
  ],
})
const modifyInfo = reactive({
  visible: false,
  orderId: '',
  title: '修改跟台记录',
})
const withTableOrderDetailInfo = reactive({
  visible: false,
  id: '',
})
const withTableAcceptOrderDetailInfo = reactive({
  visible: false,
  id: '',
})
const modifyAcceptInfo = reactive({
  visible: false,
  acceptOrderNo: '',
  acceptOrderId: '',
  supplierId: '',
  supplierName: '',
  orderId: '',
  title: '修改跟台记录',
})
const modifyAcceptNumberInfo = reactive({
  visible: false,
  acceptOrderNo: '',
  acceptOrderId: '',
  supplierId: '',
  supplierName: '',
  orderId: '',
  title: '修改跟台记录',
})
const printerInfo = reactive({
  visible: false,
  data: {},
})
const individualInfo = reactive({
  visible: false,
  query: {},
  info: {},
})
const receivingDetailInfo = reactive({
  visible: false,
  id: '',
})
const consumeDetailInfo = reactive({
  visible: false,
  id: '',
})
const formInfo = ref({
  data: {},
  fieldList: [{ label: '撤回数量', value: 'invalidQty', type: 'slot' }],
  labelWidth: '180px',
})
const revokeDialogInfo = ref({
  title: '撤回',
  width: '400px',
  revokeVisible: false,
  btLoading: false,
  btList: [
    { label: '关闭', event: revokeHandleClose, show: true },
    { label: '确定', event: revokeHandleSave, show: true },
  ],
})
const canPrint = computed(() => {
  return proxy.$permission('withTableRecordOrder:printOrderDetails')
})
const showDialog = computed({
  get() {
    return props.visible
  },
  set(newValue) {
    emit('update:visible', newValue) // 更新父组件visible
  },
})
const canPrintQrCode = computed(() => {
  return (
    proxy.$permission('withTableRecordOrder:printCode') &&
    (infoList.data.status === 2 || infoList.data.status === 3)
  )
})

let obj = {}
tableInfo.fieldList = Object.values({
  ...proxy.$fn.deepClone(proxy.$fieldfList.FieldList),
  ...obj,
})
getMain()

function ifRenderValue(row) {
  return (
    row.codeType !== 1 &&
    row.codeType !== 3 &&
    (infoList.data.status === 2 || infoList.data.status === 3)
  )
}
function ifRenderRevoke() {
  return infoList.data.status === 3
}
function largeMax(row) {
  if (row.qtyOperateMode === 2) {
    return parseInt(row.invalidCalcQty / row.unitConvertCoefficient)
  } else {
    return row.invalidQty
  }
}
function smallMax(row) {
  let largeUnitQty = parseInt(row.invalidCalcQty / row.unitConvertCoefficient)
  if (largeUnitQty === 0 || row.largeUnitQty === largeUnitQty) {
    return parseInt(row.invalidCalcQty % row.unitConvertCoefficient)
  } else {
    return row.unitConvertCoefficient - 1
  }
}
function changeLarge(e, row) {
  let largeUnitQty = parseInt(row.invalidCalcQty / row.unitConvertCoefficient)
  if (row.qtyOperateMode === 2 && row.unitConvertCoefficient > 1) {
    if (largeUnitQty > 0 && e === largeUnitQty) {
      let smallUnitQty = parseInt(
        row.invalidCalcQty % row.unitConvertCoefficient
      )
      if (row.smallUnitQty > smallUnitQty) {
        row.smallUnitQty = smallUnitQty
      }
    }
  }
}
function update() {
  if (infoList.data.acceptOrderId && infoList.data.acceptOrderNo) {
    if (infoList.data.manageMode === 1) {
      modifyAcceptNumberInfo.orderId = props.id
      modifyAcceptNumberInfo.visible = true
      modifyAcceptNumberInfo.acceptOrderId = infoList.data.acceptOrderId
      modifyAcceptNumberInfo.acceptOrderNo = infoList.data.acceptOrderNo
      modifyAcceptNumberInfo.supplierId = infoList.data.supplierId
      modifyAcceptNumberInfo.supplierName = infoList.data.supplierName
    } else if (infoList.data.manageMode === 0) {
      modifyAcceptInfo.orderId = props.id
      modifyAcceptInfo.visible = true
      modifyAcceptInfo.acceptOrderId = infoList.data.acceptOrderId
      modifyAcceptInfo.acceptOrderNo = infoList.data.acceptOrderNo
      modifyAcceptInfo.supplierId = infoList.data.supplierId
      modifyAcceptInfo.supplierName = infoList.data.supplierName
    }
  } else {
    modifyInfo.visible = true
    modifyInfo.orderId = props.id
  }
}
//提交
function submit() {
  withTableRecordOrderSubmit([props.id]).then((res) => {
    if (res && res.success) {
      getList()
      getMain()
      getMainRelationList()
    }
  })
}
//撤回
function revoke() {
  withTableRecordOrderRevoke([props.id]).then((res) => {
    if (res && res.success) {
      getList()
      getMain()
      getMainRelationList()
    }
  })
}
function ratify() {
  //批准
  withTableRecordOrderRatify([props.id]).then((res) => {
    if (res && res.success) {
      getList()
      getMain()
      getMainRelationList()
    }
  })
}
function noTraceRevoke(row) {
  //无痕撤回
  if (row.codeType === 1 || row.codeType === 4) {
    console.log(row)
    formInfo.value.data = proxy.$fn.deepClone(row)
    formInfo.value.data.invalidCalcQty = proxy.$fn.deepClone(row.calcQty)
    formInfo.value.data.invalidQty = proxy.$fn.deepClone(row.qty)
    revokeDialogInfo.value.revokeVisible = true
    console.log(formInfo.value.data)
  } else if (row.codeType === 2 || row.codeType === 3) {
    revokeSave(row)
  }
}
function revokeSave(row) {
  withTableRecordOrderRevokeDetail(row).then((res) => {
    if (res && res.success) {
      returnBack()
    }
  })
}
function revokeHandleSave() {
  let smallUnitQty = parseFloat(formInfo.value.data.smallUnitQty || 0)
  let unitConvertCoefficient = parseFloat(
    formInfo.value.data.unitConvertCoefficient || 1
  )
  let largeUnitQty = parseFloat(formInfo.value.data.largeUnitQty || 0)
  let calcQty = proxy.$fn.accAdd(
    proxy.$fn.accMul(largeUnitQty, unitConvertCoefficient),
    smallUnitQty
  )
  let qty = proxy.$fn.accDiv(calcQty, unitConvertCoefficient)
  formInfo.value.data.calcQty = calcQty
  formInfo.value.data.qty = qty
  console.log(formInfo.value.data)
  if (calcQty <= 0) {
    proxy.$message({
      message: '请输入撤回数量',
      type: 'warning',
      duration: 3500,
      showClose: true,
    })
    return
  }
  revokeSave(formInfo.value.data)
}
function returnBack() {
  showDialog.value = false
  emit('returnBack')
}
//撤回弹窗关闭
function revokeHandleClose() {
  //清空数据
  formInfo.value.data = {}
  revokeDialogInfo.value.revokeVisible = false
}
function reject() {
  //驳回
  proxy
    .$prompt('请输入驳回理由', '提示', {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      inputValidator: isNotEmptyString.value,
      inputErrorMessage: '请输入驳回理由',
    })
    .then(({ value }) => {
      const params = {
        ids: [props.id],
        rejectReason: value,
      }
      withTableRecordOrderRejecty(params).then((res) => {
        if (res && res.success) {
          getList()
          getMain()
          getMainRelationList()
        }
      })
    })
}
//导出excel
async function exportExcel() {
  withTableRecordOrderExcelOrder(filterInfo.query).then((resp) => {
    if (resp) {
      proxy.$fn.parseExcel(resp)
    }
  })
}
const templateArr = ref([])
const popoverVisible = ref(false)
//打印
function print() {
  selectByCodeAndDept({
    tempCode: 'withTableRecordDetail',
    deptId: infoList.data.deptId,
  }).then((res) => {
    if (res && res.success) {
      templateArr.value = res.data
      popoverVisible.value = true
      // 一条数据则直接打印
      if (templateArr.value.length === 1) {
        proxy.$refs.popoverShow.hidePopover()
        doPrint({
          name: templateArr.value[0].ureportName,
          params: {
            orderId: props.id,
          },
          callback: printCallback,
          data: {},
        })
      }
    }
  })
}
function printCallback() {
  try {
    // 打印成功增加打印次数
    updatePrintCount({
      orderNo: infoList.data.orderNo,
      orderId: props.id,
      orderType: 76,
    })
  } catch (error) {}
}
function tempClick(item) {
  doPrint({
    name: item.ureportName,
    params: {
      orderId: props.id,
    },
    callback: printCallback,
    data: {},
  })
  popoverVisible.value = false
}
function getPrintData(temp) {
  let params = {
    tableKey:
      'withTableRecordOrderDetail-com.slip.spd.entity.vo.withtable.WithTableRecordOrderDetailVO',
    orderIds: [props.id],
  }
  withTableRecordOrderPrintOrder(params).then((res) => {
    if (res.success && res) {
      let data = proxy.$fn.deepClone(res.data)
      let newData = data.map((item) => {
        return {
          ...item,
          ...item.orderInfo,
        }
      })
      proxy.$lodop.preview(temp, newData)
    }
  })
}
//打印单个二维码
function printSingleQrCode(row = undefined) {
  if (!row.qrCode) {
    proxy.$message({
      message: '没有生成二维码，不能打印',
      type: 'warning',
      duration: 3500,
      showClose: true,
    })
    return
  }

  let ids
  if (row.groupConcatIds) {
    //未定义表示没有分组条件
    ids = proxy.$fn.splitArr(row.groupConcatIds)
  } else {
    ids = [row.id]
  }
  if (ids.length > 0) {
    withTableRecordOrderDetailPrintQrCodeVO(ids).then((resp) => {
      if (resp && resp.success) {
        printerInfo.visible = true
        printerInfo.data = resp.data
      }
    })
  }
}
//打印整单的二维码
function pringQrCode() {
  let ids = []
  ids.push(props.id)
  if (ids.length > 0) {
    withTableRecordOrderPrintQrCode(ids).then((resp) => {
      if (resp && resp.success) {
        printerInfo.visible = true
        printerInfo.data = resp.data
      }
    })
  }
}
function printerCallBack(printer) {
  if (printer !== false) {
    proxy.$print.buildRenderBarCode(printerInfo.data, printer)
  }
  printerInfo.visible = false
}
function showDetail(row) {
  //个体详情
  let ids
  if (row.groupConcatIds) {
    //未定义表示没有分组条件
    ids = row.groupConcatIds
  } else {
    ids = '' + row.id
  }
  individualInfo.query = {
    id: {
      queryType: 'IN',
      queryCategory: 'AND',
      value: ids,
    },
    orderId: {
      queryType: 'EQUALS',
      queryCategory: 'AND',
      value: props.id,
    },
  }
  individualInfo.info = row
  individualInfo.visible = true
}
function getList() {
  getWithTableRecordOrderDetailAll(filterInfo.query).then((resp) => {
    if (resp && resp.success) {
      tableInfo.data = resp.data
    }
  })
}
function handleTabClick(tab) {
  const name = tab.paneName
  if (name === 'first') {
    getMainRelationList()
  }
}
function getMainRelationList() {
  getMainRelationOrderAll(mainRelationTableInfo.query).then((res) => {
    if (res && res.success) {
      mainRelationTableInfo.data = res.data
    }
  })
}
function showDetailLink(row) {
  if (row.relationOrderType === 79) {
    withTableOrderDetailInfo.visible = true
    withTableOrderDetailInfo.id = row.relationOrderId
  } else if (row.relationOrderType === 80) {
    withTableAcceptOrderDetailInfo.visible = true
    withTableAcceptOrderDetailInfo.id = row.relationOrderId
  } else if (row.relationOrderType === 15) {
    //收货
    receivingDetailInfo.id = row.relationOrderId
    receivingDetailInfo.visible = true
  } else if (row.relationOrderType === 25) {
    //消耗单
    detailConsumeOrder(row.relationOrderId).then((res) => {
      if (res && res.success) {
        if (res.data && res.data.id) {
          consumeDetailInfo.id = row.relationOrderId
          consumeDetailInfo.visible = true
        } else {
          proxy.$message({
            message: '当前跳转单据不存在，不能跳转，请刷新数据',
            type: 'warning',
            duration: 3500,
            showClose: true,
          })
          return
        }
      }
    })
  }
}

function getMain() {
  getWithTableRecordOrderById(props.id).then((resp) => {
    if (resp && resp.success) {
      infoList.data = resp.data
      getCustomize()
    }
  })
}
function returnModify() {
  getMain()
  getList()
  getMainRelationList()
}
function getCustomize() {
  let param = {
    tableKey:
      'withTableRecordOrderDetail-com.slip.spd.entity.vo.withtable.WithTableRecordOrderDetailVO',
  }
  getCustomizeSetting(param).then((res) => {
    if (res && res.success) {
      let data = res.data
      filterInfo.query.customizeUserVO = data
      let obj = proxy.$fn.setFieldList(tableInfo.fieldList, data.detail, true)
      tableInfo.fieldList = obj.fieldList
      getList()
      getMainRelationList()
    }
  })
}
</script>

<style scoped></style>
